document.getElementById("app").style.opacity = "1";
let vm = new Vue({
  el: "#app",
  data() {
    return {
      card1: [],
      card1Index: 0,

      card2: [],
      card2Index: 0,

      card3: [],
      card3Index: 0,

      card4: [],
      card4Index: 0,

      area: ["广东", "浙江", "江苏", "其他"],
      activeIndex: 0,
      swiperlast: {}, //最后一个轮播图
    };
  },
  methods: {
    jumpJob(id) {
      console.log(id);
      window.open(`https://www.jjrw.com/job/${id}.html`);
    },
    openConpany(coid, islt = true) {
      islt == true
        ? window.open(`https://www.jjrw.com/company/${coid}.html?source=3`)
        : window.open(`https://www.jjrw.com/company/${coid}.html`);
    },
    selectArea(index) {
      this.activeIndex = index;
      this.swiperlast.result();
      this.initSelfSwiper();
    },
    initSelfSwiper() {
      this.$nextTick(() => {
        this.swiperlast = new bannerCard(
          "swiper2",
          {
            left: "swiper2_left",
            right: "swiper2_right",
          },
          true,
          this.$refs.swiper2
        );
        this.swiperlast.listenMouse((index) => {
          this.card4Index = index;
        });
        this.swiperlast.touch((index) => {
          this.card4Index = index;
        });
      });
    },
  },
  created() {
    this.card1 = carddata.card1;
    this.card2 = carddata.card2;
    this.card3 = carddata.card3;
    this.card4 = carddata.card4;
    this.$nextTick(() => {
      //实例化第一个卡片
      let swiper1 = new bannerCard(
        "swiper1",
        {
          left: "swiper1_left",
          right: "swiper1_right",
        },
        false,
        this.$refs.swiper1
      );
      swiper1.listenMouse((index) => {
        this.card1Index = index;
      });
      swiper1.touch((index) => {
        this.card1Index = index;
      });

      //实例化第二个
      let swiper3 = new Swiper("#swiper3", {
        loop: true,
        autoplay: 3000,
        autoplayDisableOnInteraction: false,
        onSlideChangeEnd: (swiper) => {
          this.card2Index = swiper.realIndex;
        },
      });
      $(".card2_le").click(function () {
        swiper3.slidePrev();
      });
      $(".card2_ri").click(function () {
        swiper3.slideNext();
      });

      let swiper4 = new Swiper("#swiper4", {
        loop: true,
        autoplay: 3000,
        autoplayDisableOnInteraction: false,
        onSlideChangeEnd: (swiper) => {
          this.card3Index = swiper.realIndex;
        },
      });
      $(".card3_le").click(function () {
        swiper4.slidePrev();
      });
      $(".card3_ri").click(function () {
        swiper4.slideNext();
      });
      this.initSelfSwiper();
    });
  },
  computed: {
    card1Progress() {
      return parseInt(478 / this.card1.length);
    },
    card2Progress() {
      return parseInt(478 / this.card2.length);
    },
  },
});
